package com.example.mapper;

import com.example.entity.Dorm;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 操作dorm相关数据接口
*/
public interface DormMapper {

    /**
      * 新增
    */
    int insert(Dorm dorm);

    /**
      * 删除
    */
    int deleteById(Integer id);

    /**
      * 修改
    */
    int updateById(Dorm dorm);

    /**
      * 根据ID查询
    */
    Dorm selectById(Integer id);

    /**
      * 查询所有
    */
    List<Dorm> selectAll(Dorm dorm);

    @Select("select * from dorm where name =#{name} and building_id =#{buildingId}")
    Dorm selectByName(@Param("name") String name, @Param("buildingId")Integer buildingId);

    @Select("select distinct * from dorm")
    List<Dorm> selectAllNames();
}